package org.proxycine.gestsalles.tests;

import org.junit.Test;
import org.proxycine.gestsalles.model.entities.RoleEmploye;
import org.proxycine.gestsalles.web.beans.LoginBean;
import org.proxycine.gestsalles.web.constantes.ConstantesWeb;

import junit.framework.TestCase;


public class LoginBeanTest extends TestCase {
	
	LoginBean bean;
	
	@Test
	public void testLoginAndLogoutOk(){
		bean = new LoginBean();
		bean.setLogin("gerant");
		bean.setPassword("gerant");
		bean.valideLogin();
		assertEquals(true, bean.isLoginSucces());
			System.out.println("[TEST] LOGIN : ok");
		assertEquals(RoleEmploye.Gerant, bean.getEmployeLogged().getRole());
			System.out.println("[TEST] LOGIN : rôle employé ok");
			
	}	
	
	@Test
	public void testLoginKO(){
		bean = new LoginBean();
		bean.setLogin("loginKo");
		bean.setPassword("passwordKo");
		bean.valideLogin();
		assertEquals(false, bean.isLoginSucces());
			System.out.println("[TEST] LOGIN KO : ok");
		assertEquals(ConstantesWeb.ERROR_MESSAGE_LOGIN, bean.getErrorMsg());
			System.out.println("[TEST] LOGIN KO : message d'erreur ok");	
	}
	
}
